home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / inter / local.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-03-08  |  6.1 KB  |  180 lines

  1. VERSION 2.00
  2. Begin Form frmLocal 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "SuperChat Local"
  5.    ClientHeight    =   1365
  6.    ClientLeft      =   1050
  7.    ClientTop       =   6345
  8.    ClientWidth     =   8505
  9.    ControlBox      =   0   'False
  10.    Height          =   1770
  11.    Icon            =   LOCAL.FRX:0000
  12.    Left            =   990
  13.    LinkTopic       =   "Form2"
  14.    MaxButton       =   0   'False
  15.    MDIChild        =   -1  'True
  16.    ScaleHeight     =   91
  17.    ScaleMode       =   3  'Pixel
  18.    ScaleWidth      =   567
  19.    Top             =   6000
  20.    Width           =   8625
  21.    Begin CommandButton btnQuit 
  22.       Caption         =   "E&xit"
  23.       Height          =   375
  24.       Left            =   7200
  25.       TabIndex        =   2
  26.       Top             =   120
  27.       Width           =   1140
  28.    End
  29.    Begin CommandButton btnConnect 
  30.       Caption         =   "&Call"
  31.       Height          =   375
  32.       Left            =   7200
  33.       TabIndex        =   1
  34.       Top             =   600
  35.       Width           =   1140
  36.    End
  37.    Begin dsSocket dssLocal 
  38.       DataSize        =   2048
  39.       Left            =   6720
  40.       Linger          =   0   'False
  41.       LocalPort       =   0
  42.       RemoteDotAddr   =   ""
  43.       RemoteHost      =   ""
  44.       RemotePort      =   0
  45.       ServiceName     =   ""
  46.       Timeout         =   0
  47.       Top             =   945
  48.    End
  49.    Begin TextBox txtLocal 
  50.       Enabled         =   0   'False
  51.       FontBold        =   0   'False
  52.       FontItalic      =   0   'False
  53.       FontName        =   "MS Sans Serif"
  54.       FontSize        =   9.75
  55.       FontStrikethru  =   0   'False
  56.       FontUnderline   =   0   'False
  57.       Height          =   360
  58.       Left            =   360
  59.       ScrollBars      =   2  'Vertical
  60.       TabIndex        =   0
  61.       Top             =   600
  62.       Width           =   6405
  63.    End
  64.    Begin Label Label1 
  65.       AutoSize        =   -1  'True
  66.       Caption         =   "Type Here:"
  67.       Height          =   195
  68.       Left            =   90
  69.       TabIndex        =   3
  70.       Top             =   240
  71.       Width           =   960
  72.    End
  73. DefInt A-Z
  74. Sub btnConnect_Click ()
  75.     '-- Show the connect form
  76.     frmConnect.Show 1
  77. End Sub
  78. Sub btnQuit_Click ()
  79.     Unload frmChat
  80. End Sub
  81. Sub dssLocal_Accept (SocketID As Integer)
  82. '-- Accept occurs when someone connects to YOU.
  83.     '-- We need a new form
  84.     Dim Frm As Form
  85.     '-- NumNodes is the number of people connected
  86.     NumNodes = NumNodes + 1
  87.     '-- Load a new form and set its tag to a non-zero
  88.     '   value so we can identify it as a node
  89.     Set Frm = New frmNode
  90.     Frm.Tag = Str$(NumNodes)
  91.     '-- Setting the Socket property hands over the
  92.     '   connection to the new form's DsSocket control
  93.     Frm.dssNode.Socket = SocketID
  94.     '-- Determine the user's alias
  95.     If Len(frmConnect.txtAlias) = 0 Then
  96.         frmConnect.txtAlias = frmLocal.dssLocal.LocalName
  97.     End If
  98.     '-- Send the alias to the connected user, so they can
  99.     '   see who they're talking to
  100.     Frm.dssNode.Send = "NAME=" & frmConnect.txtAlias & "~"
  101.     '-- Make the Chat window "pop up" if its minimized
  102.     If frmChat.WindowState = 1 Then
  103.         frmChat.WindowState = 0
  104.     End If
  105.     '-- Move the local form to the bottom of the screen and
  106.     '   tile horizontally, putting the local form on the
  107.     '   bottom
  108.     frmLocal.Top = frmChat.Height
  109.     frmChat.Arrange 1
  110.     btnConnect.Enabled = False
  111.     txtLocal.Enabled = True
  112. End Sub
  113. Sub dssLocal_Connect ()
  114. '-- You have successfully connected to another
  115. '   superchat host.
  116.     '-- We need a new form
  117.     Dim Frm As Form
  118.     '-- NumNodes is the number of people connected
  119.     NumNodes = NumNodes + 1
  120.     '-- Load a new form and set its tag to a non-zero
  121.     '   value so we can identify it as a node
  122.     Set Frm = New frmNode
  123.     Frm.Tag = Str$(NumNodes)
  124.     '-- Setting the Socket property hands over the
  125.     '   connection to the new form's DsSocket control
  126.     Frm.dssNode.Socket = dssLocal.Socket
  127.     '-- Send the alias to the connected user, so they can
  128.     '   see who they're talking to
  129.     Frm.dssNode.Send = "NAME=" & frmConnect.txtAlias & "~"
  130.     '-- Move the local form to the bottom of the screen and
  131.     '   tile horizontally, putting the local form on the
  132.     '   bottom
  133.     frmLocal.Top = frmChat.Height
  134.     frmChat.Arrange 1
  135.     btnConnect.Enabled = False
  136.     txtLocal.Enabled = True
  137. End Sub
  138. Sub dssLocal_Exception (ErrorCode As Integer, ErrorDesc As String)
  139.     If ErrorCode = DSSOCK_DISCONNECTED Then
  140.         btnConnect.Enabled = True
  141.         txtLocal.Enabled = False
  142.     End If
  143. End Sub
  144. Sub dssLocal_Listen ()
  145. '-- This means SuperChat is listening
  146.     Caption = "Port" & Str$(ListenPort) & " Ready"
  147. End Sub
  148. Sub Form_Load ()
  149.     '-- Initailize the alias field in the connect window.
  150.     frmConnect.txtAlias = frmLocal.dssLocal.LocalName
  151. End Sub
  152. Sub Form_Unload (Cancel As Integer)
  153.     '-- Close the socket connection if its open.
  154.     On Error Resume Next
  155.     dssLocal.Action = DSSOCK_CLOSE
  156. End Sub
  157. Sub txtLocal_KeyPress (KeyAscii As Integer)
  158.     Static szLine As String
  159.     Select Case KeyAscii
  160.         Case 13 '-- C/R
  161.             '-- Send the keystroke through all nodes
  162.             '   effectively broadcasting your keystrokes.
  163.             For i = 0 To Forms.Count - 1
  164.                 If Len(Forms(i).Tag) Then
  165.                     Forms(i).txtNode.SelStart = Len(Forms(i).txtNode)
  166.                     Forms(i).txtNode.SelText = "> " & szLine & Chr$(13) & Chr$(10)
  167.                     Forms(i).dssNode.Send = szLine & Chr$(13) & Chr$(10)
  168.                 End If
  169.             Next
  170.             szLine = ""
  171.             txtLocal = ""
  172.             KeyAscii = 0
  173.         Case 8  '-- BackSpace
  174.             '-- remove the last character
  175.             szLine = Left$(szLine, Len(szLine) - 1)
  176.         Case Else
  177.             szLine = szLine & Chr$(KeyAscii)
  178.     End Select
  179. End Sub
  180.